package com.web.dao;

import com.web.entity.KftApply;

import static org.apache.ibatis.jdbc.SqlBuilder.*;

public class KftApplySqlProvider {

    public String insertSelective(KftApply record) {
        BEGIN();
        INSERT_INTO("t_kft_apply");

        if (record.getmId() != null) {
            VALUES("m_id", "#{mId,jdbcType=BIGINT}");
        }

        if (record.getName() != null) {
            VALUES("name", "#{name,jdbcType=VARCHAR}");
        }

        if (record.getPhone() != null) {
            VALUES("phone", "#{phone,jdbcType=VARCHAR}");
        }

        if (record.getMerchantName() != null) {
            VALUES("merchant_name", "#{merchantName,jdbcType=VARCHAR}");
        }

        if (record.getIdCardHold() != null) {
            VALUES("id_card_hold", "#{idCardHold,jdbcType=VARCHAR}");
        }

        if (record.getBankOpen() != null) {
            VALUES("bank_open", "#{bankOpen,jdbcType=VARCHAR}");
        }

        if (record.getBankCardFront() != null) {
            VALUES("bank_card_front", "#{bankCardFront,jdbcType=VARCHAR}");
        }

        if (record.getBankCardBack() != null) {
            VALUES("bank_card_back", "#{bankCardBack,jdbcType=VARCHAR}");
        }

        if (record.getStoreFront() != null) {
            VALUES("store_front", "#{storeFront,jdbcType=VARCHAR}");
        }

        if (record.getStatus() != null) {
            VALUES("status", "#{status,jdbcType=TINYINT}");
        }

        if (record.getReason() != null) {
            VALUES("reason", "#{reason,jdbcType=VARCHAR}");
        }


        if (record.getIdValidDate() != null) {
            VALUES("id_valid_date "," #{idValidDate,jdbcType=VARCHAR}");
        }

        if (record.getLicenceValidDate() != null) {
            VALUES("licence_valid_date"," #{licenceValidDate,jdbcType=VARCHAR}");
        }


        if (record.getKftId() != null) {
            VALUES("kft_id", "#{kftId,jdbcType=VARCHAR}");
        }

        if (record.getCreateTime() != null) {
            VALUES("create_time", "#{createTime,jdbcType=TIMESTAMP}");
        }

        if (record.getModifyTime() != null) {
            VALUES("modify_time", "#{modifyTime,jdbcType=TIMESTAMP}");
        }

        return SQL();
    }

    public String updateByPrimaryKeySelective(KftApply record) {
        BEGIN();
        UPDATE("t_kft_apply");

        if (record.getmId() != null) {
            SET("m_id = #{mId,jdbcType=BIGINT}");
        }

        if (record.getName() != null) {
            SET("name = #{name,jdbcType=VARCHAR}");
        }

        if (record.getPhone() != null) {
            SET("phone = #{phone,jdbcType=VARCHAR}");
        }

        if (record.getMerchantName() != null) {
            SET("merchant_name = #{merchantName,jdbcType=VARCHAR}");
        }

        if (record.getBankOpen() != null) {
            SET("bank_open = #{bankOpen,jdbcType=VARCHAR}");
        }

        if (record.getIdCardHold() != null) {
            SET("id_card_hold = #{idCardHold,jdbcType=VARCHAR}");
        }

        if (record.getBankCardFront() != null) {
            SET("bank_card_front = #{bankCardFront,jdbcType=VARCHAR}");
        }

        if (record.getBankCardBack() != null) {
            SET("bank_card_back = #{bankCardBack,jdbcType=VARCHAR}");
        }

        if (record.getStoreFront() != null) {
            SET("store_front = #{storeFront,jdbcType=VARCHAR}");
        }

        if (record.getStatus() != null) {
            SET("status = #{status,jdbcType=TINYINT}");
        }

        if (record.getReason() != null) {
            SET("reason = #{reason,jdbcType=VARCHAR}");
        }

        if (record.getIdValidDate() != null) {
            SET("id_valid_date = #{idValidDate,jdbcType=VARCHAR}");
        }

        if (record.getLicenceValidDate() != null) {
            SET("licence_valid_date = #{licenceValidDate,jdbcType=VARCHAR}");
        }

        if (record.getKftId() != null) {
            SET("kft_id = #{kftId,jdbcType=VARCHAR}");
        }

        if (record.getCreateTime() != null) {
            SET("create_time = #{createTime,jdbcType=TIMESTAMP}");
        }

        if (record.getModifyTime() != null) {
            SET("modify_time = #{modifyTime,jdbcType=TIMESTAMP}");
        }

        WHERE("id = #{id,jdbcType=BIGINT}");

        return SQL();
    }
}